net: hns3: fix a bug caused by udelay
authorPeng Li <lipeng321@huawei.com>
Thu, 20 Dec 2018 03:52:00 +0000 (11:52 +0800)
committerSalvatore Bonaccorso <carnil@debian.org>
Thu, 18 Jul 2019 22:23:17 +0000 (23:23 +0100)
udelay() in driver may always occupancy processor. If there is only
one cpu in system, the VF driver may initialize fail when insmod
PF and VF driver in the same system. This patch use msleep() to free
cpu when VF wait PF message.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Gbp-Pq: Topic bugfix/arm64/huawei-taishan
Gbp-Pq: Name 0024-net-hns3-fix-a-bug-caused-by-udelay.patch

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c

index e9d5a4f96304e114722caea9c21509a4e0b6cc6c..499131840041ae467611f17588a27cf06f9699ad 100644 (file)
@@ -26,7 +26,7 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1,
                                u8 *resp_data, u16 resp_len)
 {
 #define HCLGEVF_MAX_TRY_TIMES  500
-#define HCLGEVF_SLEEP_USCOEND  1000
+#define HCLGEVF_SLEEP_USECOND  1000
        struct hclgevf_mbx_resp_status *mbx_resp;
        u16 r_code0, r_code1;
        int i = 0;
@@ -40,7 +40,7 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1,
        }
 
        while ((!hdev->mbx_resp.received_resp) && (i < HCLGEVF_MAX_TRY_TIMES)) {
-               udelay(HCLGEVF_SLEEP_USCOEND);
+               usleep_range(HCLGEVF_SLEEP_USECOND, HCLGEVF_SLEEP_USECOND * 2);
                i++;
        }